package com.agritech.common;

/**
 * 统一响应结果类，封装接口返回数据格式
 */
public class Result {

    private Integer code; // 状态码
    private String message; // 提示信息
    private Object data; // 返回数据

    public Result() {
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // Getters and Setters
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    // 静态工厂方法
    public static Result ok() {
        return new Result(200, "操作成功", null);
    }

    public static Result ok(String message) {
        return new Result(200, message, null);
    }

    public static Result ok(Object data) {
        return new Result(200, "操作成功", data);
    }

    public static Result ok(String message, Object data) {
        return new Result(200, message, data);
    }

    public static Result error() {
        return new Result(500, "操作失败", null);
    }

    public static Result error(String message) {
        return new Result(500, message, null);
    }

    public static Result error(Integer code, String message) {
        return new Result(code, message, null);
    }
}